{%- set this_nodename = grains['nodename'] %}
{%- set netiface = salt.caasp_pillar.get('hw:netiface') -%}
{%- set this_ip = grains['ip4_interfaces'][netiface][0] -%}
{%-  set pod_infra_container_image = salt.caasp_pillar.get('kubernetes:lookup:kubelet:pod_infra_container_image', False) -%}
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/kubernetes/kubernetes
After=containerd.service
Requires=containerd.service

[Service]
ExecStart=/usr/local/bin/kubelet \
  --config=/etc/kubernetes/kubelet-config.yaml \
{%- if salt.caasp_pillar.get('kubernetes:lookup:kubelet:pod_infra_container_image')  %}
  --pod-infra-container-image={{ pod_infra_container_image }} \
{%- endif %}
  --container-runtime=remote \
  --container-runtime-endpoint=unix:///var/run/containerd/containerd.sock \
  --alsologtostderr=true \
  --logtostderr=false \
  --image-pull-progress-deadline=5m \
  --kubeconfig={{ pillar['paths']['kubelet_config'] }} \
  --register-node=true \
  --network-plugin=cni \
  --cni-conf-dir=/etc/cni/net.d \
  --cni-bin-dir=/opt/cni/bin  \
  --feature-gates="RotateKubeletServerCertificate=true,CustomResourceValidation=true" \
  --v=2
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
